# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer:
pkgname=ck
pkgver=0.7.1
pkgrel=0
pkgdesc="Concurrency primitives, safe memory reclamation mechanisms and non-blocking (including lock-free) data structures"
url="http://concurrencykit.org/"
arch="all"
license="BSD-2-Clause AND Apache-2.0"
makedepends="linux-headers"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
options="!check" # TODO: pass locally but hang on CI
source="$pkgname-$pkgver.tar.gz::https://github.com/concurrencykit/ck/archive/refs/tags/$pkgver.tar.gz"

# GitLab CI and builders run armhf/armv7 as 32-bit arches on aarch64.
# Thus, we cannot rely on the uname -m output on these platforms.
case "$CTARGET_ARCH" in
armhf) export PLATFORM=armv6l ;;
armv7) export PLATFORM=armv7l ;;
esac

# Platforms which are not natively supported by ck can be supported by
# compiling with --use-cc-builtins. This has a performance penalty but
# allows us to support software depending on ck on these platforms.
#
# Regarding native support:
#
#   * riscv64: https://github.com/concurrencykit/ck/issues/169
#
_conf_opts=""
case "$CTARGET_ARCH" in
riscv64) _conf_opts="--use-cc-builtins" ;;
esac

build() {
	./configure \
		--build=\$CBUILD \
		--host=\$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var $_conf_opts
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
48768e7adf05b818f2951b246c90185071d6c3f874218349183d96b7887830f9505f9fa58576e9933862486e8543097df0ee667518009a3946d1edc19fc253f7  ck-0.7.1.tar.gz
"
